﻿using FunctionCommon;
using LogicLayer.rabbit;
using LogicLayer.xk;
using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace LogicLayer
{
    public class IOC_Factory
    {

        public  IUnityContainer container { get; set; }
        public IOC_Factory()
        {
            container = new UnityContainer();//容器
        }

        /// <summary>
        /// 依赖注入
        /// </summary>
        /// <typeparam name="Toperater">需要调用接口的调用类</typeparam>
        /// <returns></returns>
        public  Toperater GetOperater<Toperater>()
        {
            Toperater operater = container.Resolve<Toperater>();//DI（依赖注入)
            return operater;
        }



        /// <summary>
        /// 注册接口容器
        /// </summary>
        /// <typeparam name="Tinterface">接口</typeparam>
        /// <typeparam name="Tclass">实现Tinterface接口的具体类</typeparam>
        public  void register<Tinterface,Tclass>() where  Tclass:Tinterface
        {
            container.RegisterType<Tinterface, Tclass>();//注册接口与具象依赖
        }

      

    }
}
